package com.example.boot.controller;

import com.example.boot.config.Configs;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

/**
 * @RestController=@Controller+@ResponseBody 要返回试图要用controller 一般结合模板引擎
 * 要直接返回json用restcontroller 前后台分离
 * <p>
 * restcontroller默认使用了responsebody支持json,要返回试图需要用ModelAndView mv = new ModelAndView("index");
 * 在modelandview中进行试图返回
 */
@RestController
@Log4j2
public class HelloController {

    /**
     * @GetMapping("/")= @RequestMapping(value = "/", method = RequestMethod.GET)
     */
    @GetMapping("/")
    public String hello() {
        return "hello!";
    }

    @Autowired
    private Configs configs;

    @GetMapping("/print")
    public String print() {
        return configs.printAllValus();
    }

}
